package xyz.talentboy;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.web.filter.CharacterEncodingFilter;

@SpringBootApplication
public class WechatApplication extends SpringBootServletInitializer {

	public static void main(String[] args) {
		SpringApplication.run(WechatApplication.class, args);
	}

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(WechatApplication.class);
	}
	
	@Bean
	public FilterRegistrationBean filterReg(){
		FilterRegistrationBean filterBean = new FilterRegistrationBean();
		CharacterEncodingFilter chFilter = new CharacterEncodingFilter("UTF-8", true, true);
		filterBean.addUrlPatterns("/*");
		filterBean.setFilter(chFilter);
		return filterBean;
	}
	
}
